package com.web.my12306.service.impl;

import com.web.my12306.dao.IAdminDao;
import com.web.my12306.dao.IPrivilegeDao;
import com.web.my12306.dao.impl.AdminDaoImpl;
import com.web.my12306.dao.impl.PrivilegeDaoImpl;
import com.web.my12306.pojo.Admin;
import com.web.my12306.pojo.User;
import com.web.my12306.service.AdminService;

import java.util.List;
import java.util.Set;

public class AdminServiceImpl implements AdminService
{

    //类实例
    //    public static final AdminService instance = new AdminServiceImpl();

    IAdminDao iAdminDao = new AdminDaoImpl();
    Admin admin = new Admin();

    @Override
    //管理员登录
    public Admin login(String loginname, String password) {
        return iAdminDao.Login(loginname, password);
    }

    @Override
    //所有管理员
    public List<Admin> findAll() {
        return iAdminDao.findAll();
    }

    @Override
    //新增管理员
    public void addAdmin(String loginname, String password, int roleid) {
        iAdminDao.addAdmin(loginname, password, roleid);
    }

    @Override
    //根据工号查询
    public Admin findByName(String loginname) {
        return iAdminDao.findByName(loginname);
    }

    @Override
    //根据工号修改密码
    public void editPassword(String loginname, String password) {
        iAdminDao.editPassword(loginname, password);
    }

    @Override
    //查询所有普通用户
    public List<User> findAllUser() {
        return iAdminDao.findAllUser();
    }

    @Override
    public void delete(String loginname) {
        iAdminDao.delete(loginname);
    }

    @Override
    public Set<String> queryPriv(int state)
    {
        IPrivilegeDao privilegeDao=new PrivilegeDaoImpl();
        return privilegeDao.query(state);
    }
}
